#!/bin/sh

echo ""
echo "---- Compiling Assembly files"
nasm -f elf -o obj/kernel/loader.o src/kernel/loader.s

echo "---- Compiling C++ code"
g++ -o obj/kernel/kernel.o -c src/kernel/kernel.cpp -Wall -Wextra -Werror -nostdlib -nostartfiles -nodefaultlibs

echo "---- Linking kernel"
ld -T linker.ld -o bin/kernel.bin obj/kernel/loader.o obj/kernel/kernel.o

echo "---- Assembling kernel image"
cat file/stage1 file/stage2 file/pad bin/kernel.bin > bin/floppy.img

echo "---- ==DONE=="
echo ""
python -c "from os.path import getsize 
print 'Kernel size in blocks:', int(getsize('bin/kernel.bin') / 512)+1"
echo ""
